<?php
require_once 'cmClasses/trunk/autoload.php5';

class Tool{

	public function __construct(){

		$cores		= LoadGraph::getNumberOfProcessorCores();
		$loads		= sys_getloadavg();
		$load1		= $loads[0];
		$max		= max( $loads );

		$load0Relative	= 1 / ( 1 + $loads[0] / $cores );
		$load1Relative	= 1 / ( 1 + $loads[1] / $cores );
		$load2Relative	= 1 / ( 1 + $loads[2] / $cores );

		$indicator	= new UI_HTML_Indicator();
		$indicator->setOption( 'useColorAtBorder', FALSE );
		$load0GraphRelative	= $indicator->build( $load0Relative, 1 );
		$load1GraphRelative	= $indicator->build( $load1Relative, 1 );
		$load2GraphRelative	= $indicator->build( $load2Relative, 1 );
		$indicator->setOption( 'useColor', FALSE );
		$load0Graph	= $indicator->build( $loads[0] / $max, 1 );
		$load1Graph	= $indicator->build( $loads[1] / $max, 1 );
		$load2Graph	= $indicator->build( $loads[2] / $max, 1 );

		$max	= max( $loads );
		$lay2	= $loads[2] / $max;
		$lay1	= max( 0, ( $loads[1] / $max ) - $lay2 );
		$lay0	= max( 0, ( $loads[0] / $max ) - $lay2 - $lay1 );

		$body	= require_once 'template.phpt';

		$page	= new UI_HTML_PageFrame();
		$page->addStylesheet( "//cdn.int1a.net/css/bootstrap.min.css" );
		$page->addStylesheet( "//cdn.int1a.net/css/bootstrap-responsive.min.css" );
		$page->addStylesheet( "indicator.css" );
		$page->addMetaTag( 'name', 'viewport', "width=device-width, user-scalable=no" );
		$page->addBody( $body );
		print( $page->build() );
	}
}
?>
